---
title: clsProviderSearch
summary: API reference for clsProviderSearch.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-21
library: SAIF.Business.View.Provider
reference_type: embedded
---

# clsProviderSearch

`clsProviderSearch` is the multi-criteria provider-location search engine, the only type in this library that dynamically assembles its query text at runtime with a `Text.StringBuilder` and executes it directly through `SqlHelper.ResultSetQuery`, bypassing the portal/criteria retrieval pattern used by the rest of the library. It accepts a `clsSearchCriteria` object populated by the caller and returns matches as a `clsProviders` collection of `clsSearchResults` rows, silently capping results at 300.

## Purpose
- Runs a name/tax-ID/other-ID/type/service/MCO/address/phone search against `PROVIDER_LOCATION` and related tables, joining only the tables needed for the criteria supplied ([BR-SRCH-004](../../business-rules.md#br-srch-004-businessperson-selector-maps-to-business-flag), [BR-SRCH-008](../../business-rules.md#br-srch-008-search-text-normalization)).
- Unions in a registered-name match whenever a provider name is supplied, so both display name and registered name are searched ([BR-SRCH-005](../../business-rules.md#br-srch-005-provider-name-search-also-matches-registered-names)).
- Caps the result set at 300 rows, discarding excess matches without surfacing a warning to the caller ([BR-SRCH-007](../../business-rules.md#br-srch-007-search-results-capped-at-300-rows)).
- Hosts the criteria validation rules (minimum criteria, numeric zip, tax-ID length) evaluated by the BOF rule engine, though `searchForProvider` itself does not gate execution on `IsValid` ([BR-SRCH-001](../../business-rules.md#br-srch-001-at-least-one-search-field-is-required), [BR-SRCH-002](../../business-rules.md#br-srch-002-zip-code-must-be-numeric), [BR-SRCH-003](../../business-rules.md#br-srch-003-tax-id-length-limit)).

## Context
- Namespace: `SAIF.Business.View.Provider`
- Assembly/package: `SAIF.Business.View.Provider` (embedded/project-compiled); also distributed as the NuGet package `SAIF.BOF.Business.View.Provider`.

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `.ctor` | `Sub New(dpi As IDataPortalInfo)` | Constructs the search object bound to a data-portal context for subsequent `searchForProvider` calls. |
| `searchForProvider` | `Sub searchForProvider()` | Builds and executes the dynamic search query from the current `SearchCriteria`, populating `Providers` with up to 300 matching rows (OP-09, SQL-SRCH-01, [BR-SRCH-007](../../business-rules.md#br-srch-007-search-results-capped-at-300-rows)). |
| `resetSearchCriteria` | `Sub resetSearchCriteria()` | Clears the current `SearchCriteria` and result collection, preparing the object for a new search. |
| `SearchCriteria` | `Property SearchCriteria As clsSearchCriteria` | The caller-populated input model (name, tax ID, other ID, type, service, MCO, address, phone) consumed by `searchForProvider`. |
| `Providers` | `ReadOnly Property Providers As clsProviders` | The read-only collection of `clsSearchResults` rows produced by the most recent `searchForProvider` call. |
| `IsValid` | `ReadOnly Property IsValid As Boolean` (overridden from `clsBusinessBase`) | Reflects whether `SearchCriteria` currently satisfies [BR-SRCH-001](../../business-rules.md#br-srch-001-at-least-one-search-field-is-required)/[BR-SRCH-002](../../business-rules.md#br-srch-002-zip-code-must-be-numeric)/[BR-SRCH-003](../../business-rules.md#br-srch-003-tax-id-length-limit); not enforced by `searchForProvider` itself. |
| `IsDirty` | `ReadOnly Property IsDirty As Boolean` (overridden from `clsBusinessBase`) | Indicates in-memory changes to the search object; has no effect on persistence since this type performs no writes ([BR-DATA-001](../../business-rules.md#br-data-001-no-write-operations-are-supported)). |

## Behavioral notes
- OP-09: evaluates `BusinessPerson` first (`"BUSINESS"` → `BUSINESS_FLAG = 'Y'`, `"PERSON"` → `'N'`, otherwise `WHERE 1 = 1`) ([BR-SRCH-004](../../business-rules.md#br-srch-004-businessperson-selector-maps-to-business-flag)), then appends optional joins/predicates for tax ID, other ID, service type, MCO plan, name (prefix `LIKE`), provider type, street (prefix `LIKE`), city, state, zip, area code, and phone; string inputs are upper-cased/trimmed and phone strips `-`/`.` ([BR-SRCH-008](../../business-rules.md#br-srch-008-search-text-normalization)).
- Results are ordered `ORDER BY fullNAME ASC` and materialised into `clsSearchResults`, computing `SortName` via `FormatSortName` ([BR-SRCH-006](../../business-rules.md#br-srch-006-sort-name-derivation)); loading stops once the collection exceeds 299 rows with no caller-visible warning ([BR-SRCH-007](../../business-rules.md#br-srch-007-search-results-capped-at-300-rows)).
- `searchForProvider` does not check `SearchCriteria.IsValid` before executing — a caller can run a search with criteria that would fail [BR-SRCH-001](../../business-rules.md#br-srch-001-at-least-one-search-field-is-required)/[BR-SRCH-002](../../business-rules.md#br-srch-002-zip-code-must-be-numeric)/[BR-SRCH-003](../../business-rules.md#br-srch-003-tax-id-length-limit) validation.

## Constraints and usage notes
- Callers should invoke `SearchCriteria.IsValid` explicitly before calling `searchForProvider` if they want to enforce the minimum-criteria/zip/tax-ID rules, since the method does not check this itself.*
- Because the underlying query is built with string concatenation from criteria values rather than a fixed parameterized statement, unusual criteria combinations should be tested against the actual join/predicate logic described in OP-09.*
- Result sets larger than 300 rows are truncated silently; UI layers should not assume completeness for broad searches ([BR-SRCH-007](../../business-rules.md#br-srch-007-search-results-capped-at-300-rows)).

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- SAIF.Business.View.Provider/clsProviderSearch.vb
